<?php
// +----------------------------------------------------------------------
// | SparkERP 优秀的进销存系统 
// +----------------------------------------------------------------------
// | Copyright (c) 2022~2099 http://erp.sparkshop.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai  <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\controller\data;

use app\controller\Base;
use app\service\data\UnitService;

class Unit extends Base
{
    /**
     * 单位列表
     */
    public function index(UnitService $service)
    {
        return json($service->getList(input('param.')));
    }

    /**
     * 添加单位
     */
    public function add(UnitService $service)
    {
        if (request()->isPost()) {
            return json($service->addUnit(input('post.')));
        }
    }

    /**
     * 编辑单位
     */
    public function edit(UnitService $service)
    {
        if (request()->isPost()) {
            return json($service->editUnit(input('post.')));
        }
    }

    /**
     * 删除单位
     */
    public function del(UnitService $service)
    {
        return json($service->delUnit(input('param.')));
    }
}